package com.maolong.delayedprod.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.ReturnedMessage;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Component;

import java.util.Arrays;

@Component
@Slf4j
public class ReturnCallBack implements RabbitTemplate.ReturnsCallback {
    @Override
    public void returnedMessage(ReturnedMessage returned) {
        String body= Arrays.toString(returned.getMessage().getBody());
        log.info("消息发送失败, routingKey:{}, replyCode:{}, replyText:{}, exchange:{}, body:{}",returned.getRoutingKey(),returned.getReplyCode(),returned.getReplyText(),returned.getExchange(),body);
    }
}
